/******************************************************************************中
 * @brief: systask
 * @Author:   aple
 * @Date: 2022-12-14 18:06:21
 * @LastEditors: aple
 * @LastEditTime: 2023-05-26 16:02:00
 * @Verision: 1.0.0.0
 ******************************************************************************/
#ifndef __SYSTASK_H
#define __SYSTASK_H

#include <stdint.h>
#include "dataproc.h"
#include "pulse.h"
#include "rtctime.h"
#include "mytype.h"
#include "iohandle.h"
#include "fun_list.h"

#ifdef __cplusplus
extern "C"
{
#endif

#ifdef _SYSTASK_MODULE_
#define MY_EXT
#else
#define MY_EXT extern
#endif

	typedef struct
	{
		uint16_t stack_used;
		uint32_t st;
		uint32_t srand[2];
	} sys_info_type;

	typedef struct
	{
		union
		{
			uint16_t dat[10];
			struct
			{
				uu16 unlock_code[2];
				uu16 cmd_mark;
				uu16 remain_time;
				uu16 link_cnt;
				uu16 rev[2];
				uu16 unlock_src_code[3];
			} cmd;
		} ctr;
		uint16_t din[10];
		uint16_t dout[10];
		uint16_t ain[10];
		uint16_t aout[10];
		uint16_t mark[30];
		ii16 pv[10];
	} dbg_dat_type;

	typedef struct
	{
		volatile uint32_t u_tick;
		volatile uint32_t powerup_time_cnt;
		sys_info_type info;

		timer_pulse_type pulse;
		sig_time_type sig_time;
		TIME_Type rtc_time;
		uu16 bsp_dly_verify;

		struct
		{
			uu8 nor_id[4];
			uu8 nor_sr[4];
		} flash;

		struct
		{
			dbg_dat_type dat;
			uu16 remain_time;
			uu16 st;
		} dbg;

		struct
		{
			io_flt_type sd_cd;
			io_flt_extv2_type key_up;
			io_flt_extv2_type key[3];
			beep_notice_type beep;
			io_signal_type tp;
		} bios;

	} sys_run_st_type;

	MY_EXT sys_run_st_type Gst;

	// 按键接口定义-弹起边沿
	FUN_LIST_REF(KEY_S0);
	FUN_LIST_REF(KEY_S1);
	FUN_LIST_REF(KEY_S2);
	FUN_LIST_REF(KEY_UP);

#undef MY_EXT

#ifdef __cplusplus
}
#endif

#endif /* __SYSTASK_H */
